package com.iss.listener;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
import javax.servlet.http.HttpSessionBindingEvent;

@WebListener()
public class SessionListener1 implements
        HttpSessionListener {

    // Public constructor is required by servlet spec
    public SessionListener1() {
    }


    @Override
    public void sessionCreated(HttpSessionEvent httpSessionEvent) {

        httpSessionEvent.getSession().setMaxInactiveInterval(10);
        System.out.println(httpSessionEvent.getSession().getId() + " is running...");
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
        System.out.println(httpSessionEvent.getSession().getId() + " is dead!");
    }
}
